home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / debugger / ddd-1.000 / ddd-1 / ddd-1.4b / ddd / ListNode.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-21  |  3.7 KB  |  133 lines

  1. // $Id: ListNode.h,v 1.4 1995/11/21 13:50:29 zeller Exp $
  2. // Deklaration Klasse ListNode
  3.  
  4. // Copyright (C) 1995 Technische Universitaet Braunschweig, Germany.
  5. // Written by Andreas Zeller (zeller@ips.cs.tu-bs.de).
  6. // 
  7. // This file is part of the DDD Library.
  8. // 
  9. // The DDD Library is free software; you can redistribute it and/or
  10. // modify it under the terms of the GNU Library General Public
  11. // License as published by the Free Software Foundation; either
  12. // version 2 of the License, or (at your option) any later version.
  13. // 
  14. // The DDD Library is distributed in the hope that it will be useful,
  15. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17. // See the GNU Library General Public License for more details.
  18. // 
  19. // You should have received a copy of the GNU Library General Public
  20. // License along with the DDD Library -- see the file COPYING.LIB.
  21. // If not, write to the Free Software Foundation, Inc.,
  22. // 675 Mass Ave, Cambridge, MA 02139, USA.
  23. // 
  24. // DDD is the data display debugger.
  25. // For details, see the DDD World-Wide-Web page, 
  26. // `http://www.cs.tu-bs.de/softech/ddd/',
  27. // or send a mail to the DDD developers at `ddd@ips.cs.tu-bs.de'.
  28.  
  29. #ifndef _Nora_ListNode_h
  30. #define _Nora_ListNode_h
  31.  
  32. #ifdef __GNUG__
  33. #pragma interface
  34. #endif
  35.  
  36.  
  37. // Ein ListNode fasst andere Knoten k_i zu Listen zusammen. Zur Laufzeit
  38. // erzeugt ein ListNode eine ListBox mit den Ergebnissen der k_i.
  39.  
  40.  
  41. #include "assert.h"
  42. #include <iostream.h>
  43. #include "misc.h"       // max()
  44.  
  45. #include "VSLNode.h"
  46.  
  47.  
  48. // ListNode
  49.  
  50. class ListNode: public VSLNode {
  51. public:
  52.     DECLARE_TYPE_INFO
  53.  
  54. private:
  55.     VSLNode *_head;
  56.     VSLNode *_tail;
  57.  
  58. protected:
  59.     ListNode(const ListNode& node):
  60.     VSLNode(node),
  61.     _head(node._head->dup()),
  62.     _tail(node._tail->dup())
  63.     {}
  64.  
  65.     bool matches(const VSLNode& node) const
  66.     {
  67.     return VSLNode::matches(node) &&
  68.         *_head == *(((ListNode *)&node)->_head) && 
  69.         *_tail == *(((ListNode *)&node)->_tail);    // dirty trick
  70.     }
  71.  
  72. public:
  73.     ListNode(VSLNode *hd, VSLNode *tl, char *type = "ListNode"):
  74.     VSLNode(type), _head(hd), _tail(tl)
  75.     {}
  76.  
  77.     VSLNode *dup() const { return new ListNode(*this); }
  78.  
  79.     // ListNode zerstoeren: inklusive Argumenten!
  80.     ~ListNode()
  81.     {
  82.     if (_head) delete _head;
  83.     if (_tail) delete _tail;
  84.     }
  85.  
  86.     // Ressourcen
  87.     VSLNode*& head() { return _head; }
  88.     VSLNode*& tail() { return _tail; }
  89.     VSLNode* head() const { return _head; }
  90.     VSLNode* tail() const { return _tail; }
  91.  
  92.     const Box *_eval(ListBox *arglist) const;
  93.  
  94.     // Optimierung
  95.     int countSelfReferences(VSLDef *cdef, VSLDefList *deflist);
  96.     int resolveDefs(VSLDef *cdef, bool complain_recursive);
  97.     int resolveSynonyms(VSLDef *cdef, VSLNode **node);
  98.     int foldOps(VSLDef *cdef, VSLNode **node);
  99.     int foldConsts(VSLDef *cdef, VSLNode **node);
  100.     int inlineFuncs(VSLDef *cdef, VSLNode **node);
  101.     int instantiateArgs(VSLDef *cdef, VSLNode **node, VSLNode *values[],
  102.     unsigned base, unsigned n);
  103.     void countArgNodes(VSLDef *cdef, int instances[],
  104.     unsigned base, unsigned n);
  105.     int _reBase(VSLDef *cdef, unsigned newBase);
  106.  
  107.     // Sonstige Baum-Funktionen
  108.     void compilePatterns(VSLDef *cdef) const;
  109.     void uncompilePatterns(VSLDef *cdef) const;
  110.     int resolveName(VSLDef *cdef, VSLNode **node, string& name, unsigned id);
  111.     int _resolveNames(VSLDef *cdef, unsigned base);
  112.     string firstName() const;
  113.  
  114.     // Liste anhaengen
  115.     int append(VSLNode *node);
  116.  
  117.     // Namen ausgeben
  118.     void dump(ostream& s) const;
  119.     void _dumpTree(ostream& s) const;
  120.  
  121.     bool isConst() const;
  122.     bool isListNode() const { return true; }
  123.  
  124.     bool isStraight() const;
  125.  
  126.     unsigned nargs() const;
  127.  
  128.     // Repraesentations-Invariante
  129.     bool OK() const;
  130. };
  131.  
  132. #endif
  133.